
<%@page import="cn.com.dhcc.app.core.CoreEnv.CoreInitCtx"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/view/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>${appname}</title>
<%@ include file="/WEB-INF/view/common/css_js_ace.jsp"%>
<%@ include file="/WEB-INF/view/common/css_js_ztree.jsp"%>
<script type="text/javascript">
$(function() {
	$('.tipMe').tooltip({
		'placement' : 'top'
	});

	$("groupMsg").toggle(function() {
		$(this).addClass("selected");
	}, function() {
		$(this).removeClass("selected");
	});
});

/**
 * 异步加载子消息
 */
function showSubMsg(id, obj) {
	var obj = $(obj);
	var shown = obj.attr("shown");
	var loaded = obj.attr("loaded");

	$('tr[name="submsg"]').hide();
	$('a[name="iconDown"]').attr("shown", "nop");
	$('a[name="iconDown"]').html(
			'<i class="icon-chevron-down bigger-130"></i>');

	if ('nop' == shown) {
		if ('nop' == loaded) {
			$('#msg_' + id)
					.after(
							'<tr class="warning" id="loadSpin_'+id+'">'
									+ '<td colspan=5>'
									+ '<p class="text-center" style="font-size: 25px; color: #428bca;">'
									+ '<span class="icon icon-cog icon-spin"></span>'
									+ '</p>'
									+ '<p class="text-center" style="font-size: 12px; color: #428bca; margin-top: -10px; margin-bottom: 0px;">'
									+ '<span>加载中...</span>' + '</p>'
									+ '</td>' + '</tr>');
			$.ajax({
				type : "POST",
				dataType : "html",
				cache : false,
				url : _ctx + "/task/sub_task_log_list.do",
				data : {
					id : id
				},
				success : function(content) {
					$("#loadSpin_" + id).css("display", "none");
					$('#msg_' + id).after(content);
					$('.tipMe').tooltip({
						'placement' : 'top'
					});
					obj.attr("loaded", "yeap");
				},
				error : function() {
					ui.msg('信息加载错误', 0);
				}
			}).done(function() {
				//加载新内容后重新设置iframe高度
				parent.setIframeHeight( $('iframe', parent.document)[0] );
			});
		}
		$('tr[id^="submsg_' + id + '"]').show();
		obj.html('<i class="icon-chevron-up bigger-130"></i>');
		obj.attr("shown", "yeap");
		
		//var documentHeight = $('#main-container').height();
		//var test = document.getElementsByTagName("html")[0].scrollHeight;
		//$('iframe', parent.document)[0].height = 600;

		//parent.setIframeHeight( $('iframe', parent.document)[0] );
	} else {
		obj.attr("shown", "nop");
		obj.html('<i class="icon-chevron-down bigger-130"></i>');

		$('tr[id^="submsg_' + id + '"]').hide();
	}
}

	function searchClick(obj) {
		if (obj.checked) {
			window.location = _ctx
					+ "/task/task_log_list.do?id=${param.id}&checkedType="
					+ obj.value;
		} else {
			window.location = _ctx
					+ "/task/task_log_list.do?id=${param.id}";
		}
	}
	
	function syncContentInfo(id) {
		var content = $("#" + id).html();
		$("#syncContentPre").html(content.trim());
		var hiddenByClick = false;
		window.parent.iframeModal("syncContentModal", $("#syncContentModal").html(), hiddenByClick);
	
	}
function exportExcel(id){
// 		location.href=_ctx + "/structured/down_data.do?id=" + id;
	$.ajax({
		type: "POST",
		dataType:"json",
		url: _ctx + "/task/before_export.do",
		data: {id:id},
		success: function(resp){
			if(resp.status == '1'){
				location.href = _ctx + "/task/export_excel.do?id=" + id;
			} else {
				parent.ui.msg(resp.msg, 0);
			}
		},
		error:function(status, errorThrown){
			parent.ui.msg('信息加载错误', 0);
		}
	});
}
</script>
</head>
<body>
	<div class="main-container" id="main-container">
		<div class="main-container-inner">
			<div class="main-content" style="margin-left: 0px;">
				<div class="breadcrumbs" id="breadcrumbs">
					<ul class="breadcrumb">
						<li><i class="icon-home home-icon"></i> 首页</li>
						<li class="active">任务管理</li>
						<li class="active">发送日志监控</li>
					</ul>
				</div>
				<div class="page-content">
					<div class="row">
						<div class="col-xs-12">
							<div class="widget-box">
								<div class="widget-header widget-header-flat">
									<div class="widget-toolbar no-border">
										<a class="btn btn-primary btn-xs"
											href="javascript:window.location.reload()">&nbsp;<i
											class="icon-refresh bigger-120"></i>刷新&nbsp;&nbsp;</a> <a
											class="btn btn-primary btn-xs"
											href="${ctx}/task/task_list.do?listType=${param.listType}"><i
											class="icon-arrow-left icon-on-right"></i> 返回&nbsp;&nbsp;</a>
									</div>
								</div>
							</div>

							<div class="hr hr12 hr-dotted"></div>

							<span class="span5"> <label class="pull-right inline">
									<small class="muted">查看所有(默认查看有发送内容的日志记录) :</small> <input
									id="checkedType" name="checkedType" type="checkbox" value="1"
									<c:if test="${param.checkedType==1}">
									  checked='checked'
									</c:if>
									class="ace ace-switch ace-switch-5" onclick="searchClick(this)" />
									<span class="lbl"></span> </label> </span>
							<!-- /span -->
							<ul class="nav nav-tabs " id="myTab">
								<li id="lisTtype1" class="active"><a
									href="javascript:void(0);" onclick="changeListType('1');"
									class="navbar-link">发送日志列表</a></li>
							</ul>
							
							<div id="list">
								<div class="table-responsive">
									<table class="table table-striped table-bordered table-hover">
											<thead>
												<tr>
													<th class="center">序号</th>
													<th>执行开始时间</th>
													<th>执行完成时间</th>
													<th>状态</th>
													<th>操作</th>
												</tr>
											</thead>
											<tbody>
												<c:forEach var="vo" items="${_data}" varStatus="stc">
													<tr id="msg_${vo.id}">
														<td class="center">${stc.count}</td>
														
														<td><fmt:formatDate value="${vo.linkStartTime}"
																		pattern="yyyy-MM-dd HH:mm:ss" /></td>
														<td><fmt:formatDate value="${vo.linkEndTime}"
																		pattern="yyyy-MM-dd HH:mm:ss" /></td>
														<td><c:if test="${vo.logStatus eq null }">发送中</c:if> <c:if
																test="${vo.logStatus==0 }">失败</c:if> <c:if
																test="${vo.logStatus==1 }">成功</c:if></td>
														<td>

															<div class="widget-toolbar no-border" style="line-height: 0px;">
																<c:if test="${vo.total >0 && mpType eq 1}">
																	<a class="blue" href = "javascript:void(0)" onclick="exportExcel('${vo.id}')" title="导出Excel">
																		<i class="fa fa-file-excel-o bigger-130"></i>
																	</a>
																</c:if>
																<a class="blue" href="javascript:void(0)" onclick="showSubMsg('${vo.id}',this)" title="展开子任务" loaded="nop" shown="nop">
																	<i class="icon-chevron-down bigger-130"></i>
																</a>
															</div>

														</td>
													</tr>
												</c:forEach>
												
											</tbody>
										</table>
										
									<jsp:include page="/WEB-INF/view/common/pg.jsp">
										<jsp:param value="${ctx }/task/task_log_list.do"
											name="url" />
										<jsp:param value="${_total}" name="total" />
										<jsp:param value="${_urlpara}" name="urlpara" />
									</jsp:include>
								</div>
							</div>

						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	
	<div id="syncContentModal" class="modal fade" role="dialog" tabindex="-1" aria-labelledby="查看" aria-hidden="false">
		<div class="modal-dialog" style="width:800px;">
			 <div class="modal-content">
				<div class='widget-header widget-header-small'><h6 class='smaller'> 本次同步内容</h6></div>
				<pre class="prettyprint linenums" id="syncContentPre"></pre>
			 </div>
		</div>
	</div>
</body>
</html>
